package acom.dhy.qigsaw2test

import acom.dhy.qigsaw2test.qigsaw.DynamicFeature
import acom.dhy.qigsaw2test.qigsaw.registerForInstallSplitResult
import androidx.appcompat.app.AppCompatActivity
import com.google.android.play.core.splitinstall.SplitInstallManager
import com.google.android.play.core.splitinstall.SplitInstallManagerFactory

open class BaseActivity : AppCompatActivity() {
    val installManager: SplitInstallManager by lazy { SplitInstallManagerFactory.create(this) }
    val installSplit = registerForInstallSplitResult()
    fun startModule(m: DynamicFeature) {
        if (installManager.installedModules.containsAll(m.moduleNames)) {
            m.onActivityResult(this)
        } else installSplit.launch(m)
    }
}